// 封装获取频道的所有逻辑
import { useEffect,useState } from "react"
import { getChanelAPI } from "@/apis/article"

function useChannel(){
    // 1.获取频道列表的所有逻辑
    // 2.把组件要用到的数据return 出去
    // 获取频道列表
    const [channelList,setChannelList] = useState([])
    useEffect(() => {
        const getChanelList = async () => {
        const res = await getChanelAPI()
        setChannelList(res.data.data.channels)
        }
        // 调用函数
        getChanelList()
    },[])
    return { channelList }
}

export {useChannel}